package alo.p3.work;

import alo.p3.ListNode;

public class ReverseList {

    //逆置链表
    ListNode ReverseList(ListNode headNode){
        ListNode temp=null,nextNode=null;
        while (headNode!=null){
            nextNode=headNode.getNext();//2,3,4
            headNode.setNext(temp);//1->null,2->1,3->2
            temp=headNode;//1,2,3
            headNode=nextNode;//head=2,head=3,head=4
        }
        return temp;
    }
}
